Skip to content

Conversation

sharnoff
Copy link
Contributor

@sharnoff sharnoff commented Dec 9, 2020

Fixes #79868.

There's an issue I've run into a couple times while using values of type Box<dyn Any> - essentially, calling value.type_id() doesn't dereference to the trait object, but uses the implementation of Any for Box<dyn Any>, giving us the TypeId of the container instead of the object inside it.

I couldn't find any notes about this in the documentation and - while it could be inferred from existing knowledge of Rust and the blanket implemenation of Any - I think it'd be nice to have a note about it in the documentation for the any module.

Anyways, here's a first draft of a section about it. I'm happy to revise wording :)

@rust-highfive
Copy link
Contributor

r? @shepmaster

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 9, 2020
@camelid
Copy link
Member

camelid commented Dec 9, 2020

@sharnoff I edited the PR description so this closes the issue once merged.

@camelid camelid added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 9, 2020
@sharnoff
Copy link
Contributor Author

sharnoff commented Dec 9, 2020

@sharnoff I edited the PR description so this closes the issue once merged.

Cool, thanks!

Copy link
Member

@camelid camelid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits.

@sharnoff
Copy link
Contributor Author

Hey @camelid - what are the next steps for this?

@camelid
Copy link
Member

camelid commented Dec 15, 2020

You'll have to wait for your assigned reviewer, shepmaster, to review this. Sometimes reviews can take up to 10-15 days because people may have full-time jobs and/or a lot of other commitments.

@sharnoff
Copy link
Contributor Author

Cool, makes sense - thanks!

@shepmaster
Copy link
Member

@bors r+ rollup

Thanks!

@bors
Copy link
Collaborator

bors commented Jan 1, 2021

📌 Commit 72a7f73 has been approved by shepmaster

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 1, 2021
@bors
Copy link
Collaborator

bors commented Jan 2, 2021

⌛ Testing commit 72a7f73 with merge f6b6d5c...

@bors
Copy link
Collaborator

bors commented Jan 2, 2021

☀️ Test successful - checks-actions
Approved by: shepmaster
Pushing f6b6d5c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 2, 2021
@bors bors merged commit f6b6d5c into rust-lang:master Jan 2, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 2, 2021
@sharnoff sharnoff deleted the smart-pointer-Any-type_id branch August 2, 2021 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stdlib docs: Add note about getting TypeId of Box<dyn Any> ?
6 participants